package org.example.Thread01;

public class Dome_Thread02 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            for(int i=0;i<5;i++){
                System.out.println("hello Thread...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程执行完成...");
        });
        System.out.println("启动之前查看线程是否存活："+t1.isAlive());
        //启动线程
        t1.start();
        System.out.println("启动之后查看线程是否存活："+t1.isAlive());
        //等待线程结束
        t1.join();
        //保证PCB已销毁
        Thread.sleep(1000);
        System.out.println("线程结束后查看线程是否存活："+t1.isAlive());
    }
}
